package com.fourforfo.fourmall.product.dao;

import com.fourforfo.fourmall.product.entity.SpuInfoEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * spu信息
 * 
 * @author fourforfo
 * @email fourforfo@gmail.com
 * @date 2022-06-15 21:04:46
 */
@Mapper
public interface SpuInfoDao extends BaseMapper<SpuInfoEntity> {

    /**
     * //修改当前spuInfo的状态为商品已上架 状态码为：0
     * UPDATE  `pms_spu_info` SET publish_status=?,update_time=NOW() WHERE id = ?
     * @param spuId
     * @param code
     */
    void updateSpuStatus(@Param("spuId") Long spuId, @Param("code") int code);

    /**
     * 根据skuIds获取所有spuInfo信息，将spuInfo信息和对应的skuId保存到map中
     * @param skuIds
     * @return
     */
    @MapKey("sku_id")
    Map<Long, SpuInfoEntity> listSpuInfo(@Param("skuIds") List<Long> skuIds);
}
